﻿


<?php
$idst=$_GET['idst'];
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "aris";
mysql_connect($host, $user, $pass);
mysql_select_db($dbname);
mysql_query("SET NAMES UTF8");

$sql = "SELECT
machine.`name`,
result.dateStrat,
result.dateEnd,
project.idPro,
project.NPro,
project.bossproject,
project.type
FROM
result
INNER JOIN machine ON machine.id = result.idTool
INNER JOIN project ON project.idPro = result.idPro
where 
result.idStu='$idst'
ORDER BY
result.dateStrat DESC
LIMIT 0, 10

";
$rs = mysql_query($sql);
?>
<html>
<head>
	<title>ข้อมูลประวัติการใช้</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link  href="table.css" rel="Stylesheet"/>

</head>
<body>
<center>
หน้าแรก
<table  id="box-table-view">

<?php 
	$sql="SELECT * FROM 	student WHERE	student.id = '$idst'";
	$row1 = mysql_query($sql);
	while($row= mysql_fetch_array($row1) ){
	
	echo"<tr><th>รหัสนักศึกษา:".$row['id_st']."</th><th>ใช้ครั้งแรก:".$row['date_st']."</th></tr>";
	echo"<tr><th>:".$row['Pre_st']." ".$row['name_st']." ".$row['sname_st']." </th><th>เอกวิชา:".$row['class_st']."</th></tr>";
	}
	?>
	</table>
<table id="box-table-view" >
	
	
	<?php
	$txt="";
	while($row = mysql_fetch_array($rs)) {
	if($txt!=$row['idPro']){
		echo "<th COLSPAN = '3'>".$row['NPro']." ".$row['bossproject']."</th>";
		echo "<tr><th align='center'>เครื่องที่ใช้</th>      ";
		echo "<th align='center'>เวลาใช้ล่าสุด</th>    ";
		echo "<th align='center'>เวลาออก</th>   </tr> ";
		$txt=$row['idPro'];
		}
		echo"<tr>"	;	
		echo"<td  align='center'>".$row['name']."</td>"	;	
		echo"<td  align='center'>".substr($row['dateStrat'],11,8)."</br>".substr($row['dateStrat'],8,2)."-".substr($row['dateStrat'],5,2)."-".substr($row['dateStrat'],0,4)  ."</td>"	;	
		echo"<td  align='center'>".substr($row['dateEnd'],11,8)."</br>".substr($row['dateEnd'],8,2)."-".substr($row['dateEnd'],5,2)."-".substr($row['dateEnd'],0,4)  ."</td>"	;	
		echo"</tr>"	;	

	}
	?>
	
</table></center>
</body>
</html>
<?php 
function machine($idStu,$time){

$sql="
SELECT
machine.`name`
FROM
result
INNER JOIN machine ON machine.id = result.idTool
WHERE
result.idStu = '$idStu' AND
result.dateStrat = '$time'

";
$result =mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($result))
    {
    	// I doubt you actually need to run stripslashes on your data...
    	//$row = array_map('stripslashes', $row);//
    	$row = $row['name'];
    	$push[] = $row;
    }

    return $push;
}
?>